#ifndef __BMP280_H__
#define __BMP280_H__

#include "main.h"
#include "i2c.h"
#include "delay.h"

typedef struct {
    uint16_t dig_T1;
    int16_t  dig_T2;
    int16_t  dig_T3;
    uint16_t dig_P1;
    int16_t  dig_P2;
    int16_t  dig_P3;
    int16_t  dig_P4;
    int16_t  dig_P5;
    int16_t  dig_P6;
    int16_t  dig_P7;
    int16_t  dig_P8;
    int16_t  dig_P9;
} BMP280_CalibParams;

#define BMP280_ADDRESS 0x76       // I2C address of BMP280
#define BMP280_REG_CTRL_MEAS 0xF4 // Control measurement register
#define BMP280_REG_CONFIG 0xF5    // Configuration register

#define Normal_Mode 0x03          // Normal mode
#define Oversampling_16 0x05      // Oversampling x16
#define Oversampling_2 0x02    //  oversamplingx2
#define tsandby 0x00              // Standby time 0.5ms
#define IIR_filter 0x0F           // IIR filter coefficient 16
#define reset_addr 0xE0         // Reset address
#define reset_value 0xB6        // Reset value

void BMP280_Init(void);
void BMP280_Read_Pressure(void);
void BMP280_Read_Calibration(I2C_HandleTypeDef *hi2c, uint8_t address);
#endif
